SMOODEV-2513: Add connect timeout to Go fetch SDK (parity with Rust #88)#89
Open
brentrager wants to merge 1 commit into
Open
SMOODEV-2513: Add connect timeout to Go fetch SDK (parity with Rust #88)#89brentrager wants to merge 1 commit into
brentrager wants to merge 1 commit into
Conversation
Bounds only the connection-establishment phase, separate from the whole-request WithTimeout. When set (> 0), the SDK-constructed *http.Client uses an *http.Transport cloned from the default (preserving proxy/TLS/keepalive settings) whose dialer times out after the configured duration. A black-holed connect — e.g. a dead pod IP still lingering in a ClusterIP's iptables (SMOODEV-2498 / SMOODEV-2481) — then fails in ~that window and the configured retry can land on a live endpoint, instead of stalling until the whole-request timeout. Default-OFF: leaving it unset (0) preserves the previous no-connect-timeout behavior byte-for-byte. A caller-provided *http.Client (WithHTTPClient) is left untouched — the connect timeout only applies to the transport this SDK builds. Test mirrors the Rust connect_timeout_tests.rs: a request to a black-hole address (10.255.255.1:80) with a short connect timeout fails in ~that window, well under the 10x-larger whole-request timeout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Go parity for Rust #88 (SMOODEV-2513). Without a connect timeout, a black-holed connect — e.g. a dead pod IP still lingering in a ClusterIP's iptables (SMOODEV-2498 / SMOODEV-2481) — stalls until the whole-request timeout (~16s stalls observed in api-prime) before retry can land on a live endpoint.
Solution
ConnectTimeoutfield +WithConnectTimeout(d time.Duration)builder method, mirroringWithTimeout.> 0), the SDK-constructed*http.Clientuses an*http.Transportcloned fromhttp.DefaultTransport(preserving proxy/TLS/keep-alive) whoseDialContextis anet.Dialer{Timeout: connectTimeout}. Only the connection-establishment phase is bounded; slow-but-alive handlers are unaffected.Default-OFF
Leaving it unset (
0) leaves the transport untouched → behavior byte-identical to before, so existing callers are unaffected. A caller-provided*http.Client(viaWithHTTPClient) is also left untouched — the connect timeout only applies to the transport this SDK constructs.Test
Mirrors the Rust
connect_timeout_tests.rs: a request to a black-hole address (http://10.255.255.1:80/) with a 500ms connect timeout fails in ~that window (verified 0.50s), well under the 10x-larger 5s whole-request timeout. Plus a default-OFF test asserting no custom transport when unset.gofmt/go vetclean,go test ./...97 passed.🤖 Generated with Claude Code